package org.example5;

import java.lang.reflect.Field;

public class App {
    public static void main(String[] args) throws Exception {

        Bean bean = new Bean();

        Field name = bean.getClass().getDeclaredField("name");

        name.setAccessible(true);
        name.set(bean, "John Doe道格拉斯");

        //Field类中get(bean),从哪个对象中获取当前field的值
        String string =(String) name.get(bean);
        System.out.println(string);
    }
}
